const promise1 = Promise.reject(42);
const promise2 = new Promise((resolve) => setTimeout(resolve, 500, "quick"));
const promise3 = new Promise((resolve) => setTimeout(resolve, 1000, "slow"));

const promises = [promise1, promise2, promise3];
Promise.race(promises).then(value => console.log(value))
    .catch(err => console.log("err:", err));
